/**
 * @param {string} ransomNote
 * @param {string} magazine
 * @return {boolean}
 */
 var canConstruct = function(ransomNote, magazine) {
  let hash = {}
  for(let i of magazine){
    if(!hash[i]){
      hash[i] = 1
    }else{
      hash[i]++
    }
  }
  for(let i of ransomNote){
    if(!hash[i]) return false
    if(hash[i]){
      hash[i]--
    }
  }
  return true
};